<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var p1 = new Object()
    p1.name = "liqi"
    p1.sex = "男"
    p1.showName = function () {
      console.log("我的名字叫" + this.name);
    }
    p1.showSex = function () {
      console.log("我的性别是" + this.sex);
    }

    // p1.showName()
    // p1.showSex()

    function createPerson(name, sex) {
      var obj = new Object()
      obj.name = name
      obj.sex = sex
      obj.showName = function () {
        console.log("我的名字叫" + this.name);
      }
      obj.showSex = function () {
        console.log("我的性别是" + this.sex);
      }
      return obj
    }
    var p1 = createPerson("blue", "男")
    var p2 = createPerson("red", "女")
    // console.log(p1.showName === p2.showName);
    // p1.showSex()
    // p2.showName()

    var arr1 = new Array(1, 3, 5, 7, 6)
    var arr2 = new Array(2, 4, 6, 7)
    // console.log(arr1.push === arr2.push);


    function createPerson(name, sex) {
      // var obj = new Object()
      this.name = name
      this.sex = sex
      this.showName = function () {
        console.log("我的名字叫" + this.name);
      }
      this.showSex = function () {
        console.log("我的性别是" + this.sex);
      }
      // return obj
    }

    var p1 = new createPerson("blue", "男")
    var p2 = new createPerson("red", "女")
    // console.log(p1.showName === p2.showName);

    var arr1 = [11, 4, 55, 7, 8]
    var arr2 = [3, 5, 8, 9]
    Array.prototype.sum = function () {
      var res = 0
      for (var i = 0; i < this.length; i++) {
        res += this[i]
      }
      return res
    }
    // console.log(arr1.sum());
    // console.log(arr2.sum());
    // console.log(arr1.sum === arr2.sum);

    function show() {

    }
    // console.log(show.prototype);

    function Person(name, sex) {
      this.name = name
      this.sex = sex
    }
    Person.prototype.showName = function () {
      console.log("我的名字叫" + this.name);
    }
    Person.prototype.showSex = function () {
      console.log("我的性别是" + this.sex);
    }

    var p1 = new Person("liqi", "男")
    var p2 = new Person("why", "女")
    p1.showName()
    p2.showName()
    console.log(p1.showName === p2.showName);
  </script>
</body>

</html>